home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------------------
- *
- * Simple Sample AOCE Application Framework
- *
- * ©1991-1993 Apple Computer
- *
- -------------------------------------------------------------------------------------*/
- /*
- * myaoce.c -- aoce-specific routines
- *
- * change history:
- *
- * SJF 04/21/93 1.0b2 update to b2
- * SJF 03/01/93 1.0b1 added digital signatures
- * SJF 02/09/93 1.0b1 update to b1
- * SJF 10/13/92 1.0d4 update to a11
- * SJF 09/09/92 1.0d3 update to a9
- * SJF 05/07/92 1.0d2 update to a6
- * SJF 11/06/91 1.0d1 initial coding
- *
- */
-
- #define kGestaltTrap 0xA0AD
-
- #ifndef __SCRIPT__
- #include <Script.h>
- #endif
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
-
- #ifndef __FOLDERS__
- #include <Folders.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __PACKAGES__
- #include <Packages.h>
- #endif
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __OCE__
- #include <OCE.h>
- #endif
-
- #ifndef __OCESTANDARDDIRECTORY__
- #include <OCEStandardDirectory.h>
- #endif
-
- #ifndef __OCESTANDARDMAIL__
- #include <OCEStandardMail.h>
- #endif
-
- #ifndef __OCEAUTHDIR__
- #include <OCEAuthDir.h>
- #endif
-
- #ifndef __OCEERRORS__
- #include <OCEErrors.h>
- #endif
-
- #include <string.h>
-
- #include "const.h"
- #include "mytypes.h"
- #include "globals.h"
- #include "windowstuff.h"
- #include "draw.window.h"
- #include "draw.mailer.window.h"
- #include "utils.h"
- #include "myevents.h"
- #include "trapavailable.h"
- #include "windutils.h"
- #include "strconst.h"
- #include "commands.h"
- #include "mymenus.h"
- #include "digisig.h"
-
- #include "myaoce.h"
-
-
- /* static globals */
-
- static LocalIdentity gIdentity;
-
-
- pascal void DrawImageProc(long refcon, Boolean inColor);
-
-
- // HasAOCE
- //
- // returns true only of AOCE is available and running
- //
- Boolean HasAOCE(void)
- {
- OSErr err;
- long response;
-
- if (!TrapAvailable(kGestaltTrap))
- return false;
-
- err = Gestalt(gestaltOCEToolboxAttr,&response);
- if (err!=noErr)
- return false;
-
- return (response && (response << gestaltOCETBAvailable));
- }
-
-
- OSErr InitAOCE(void)
- {
- OSErr err;
-
- SetCursor(&gWatchCursor);
- err = SMPInitMailer(kSMPVersion);
- SetCursor(&qd.arrow);
-
- if (err!=noErr)
- return err;
-
- return GetLocalIdentity();
- }
-
-
- void CommAddRemoveMailer(WindowPtr window)
- {
- SetCursor(&gWatchCursor); // this may take some time
-
- if (IsWindowType(window,kDrawWindow)) // we add mailers to drawing windows
- CommAddMailer(window);
- else if (IsWindowType(window,kDrawMailerWindow))
- CommRemoveMailer(window);
-
- SetCursor(&qd.arrow); // done waiting
- }
-
-
- void CommAddMailer(WindowPtr window)
- {
- Boolean chFlag = false;
- GrafPtr savePort;
- Rect rectToInval;
-
- SendWindowMessage(window,kDeactivateMessage,&chFlag);
-
- GetPort(&savePort);
- SetPort(window);
- rectToInval = window->portRect;
- rectToInval.bottom -= kScrollBarWidth;
- rectToInval.right -= kScrollBarWidth;
- EraseRect(&rectToInval);
- InvalRect(&rectToInval);
- SetPort(savePort);
-
- MakeMailerFromDrawing(window);
- SendWindowMessage(window,kActivateMessage,&chFlag);
- }
-
-
-
- void CommRemoveMailer(WindowPtr window)
- {
- Boolean chFlag = false;
- GrafPtr savePort;
- Rect rectToInval;
-
- SendWindowMessage(window,kDeactivateMessage,&chFlag);
-
- GetPort(&savePort);
- SetPort(window);
- rectToInval = window->portRect;
- rectToInval.bottom -= kScrollBarWidth;
- rectToInval.right -= kScrollBarWidth;
- EraseRect(&rectToInval);
- InvalRect(&rectToInval);
- SetPort(savePort);
-
- MakeDrawingFromMailer(window);
- SendWindowMessage(window,kActivateMessage,&chFlag);
- }
-
-
- void CommSendLetter(WindowPtr window)
- {
- char hState;
- WInfoPtr infoPtr;
- OSErr err;
- Boolean mustAddContent;
- Str255 docTitle;
- Str255 nativeFormat;
- StringPtr nativeFormatArray[1];
-
- GetResString(nativeFormat,kAppNameID,kAppName);
-
- infoPtr = BeginWindowAccess(window,&hState);
-
- GetWTitle(window,docTitle);
- nativeFormatArray[0] = (StringPtr)nativeFormat;
- SetCursor(&qd.arrow);
- err = SMPSendOptionsDialog(window,docTitle,nativeFormatArray,1,
- kSMPNativeMask|kSMPImageMask|kSMPStandardInterchangeMask,&gPreferences.sendFormat,nil,0L,
- &gPreferences.sendFormat,&gPreferences.sendOptions);
-
- if (err==-128)
- return;
-
- if (err!=noErr) {
- DoError(err);
- return;
- }
-
- SetCursor(&gWatchCursor); // this may take some time
-
- err = SMPBeginSend(window,kAppCreator,kCDLtrMsgType,&gPreferences.sendOptions,&mustAddContent);
- if (err!=noErr) {
- SetCursor(&qd.arrow); // done waiting
- EndWindowAccess(window,hState);
- DoError(err);
- return;
- }
-
- if (mustAddContent) {
- if (err==noErr)
- err = AddLetterBlocks(window,infoPtr,&gPreferences.sendFormat);
- if (err!=noErr)
- DoError(err);
- }
-
- err = SMPEndSend(window,(err==noErr));
- if (err!=noErr)
- DoError(err);
-
- EndWindowAccess(window,hState);
-
- if ((err==noErr) && gPreferences.closeOnSend)
- CommCloseWindow(window);
-
- SetCursor(&qd.arrow); // done waiting
- }
-
-
- OSErr LoSaveLetter(WindowPtr window,WInfoPtr infoPtr,SMPSaveType saveType)
- {
- OSErr err,err2;
- FSSpec *fSpec;
- Boolean mustAddContent;
-
- err = err2 = noErr;
-
- SetCursor(&gWatchCursor); // this may take some time
-
- fSpec = &infoPtr->fileSpec;
- err = SMPBeginSave(window,fSpec,kAppCreator,kCDLtrMsgType,saveType,&mustAddContent);
- if (err!=noErr) {
- SetCursor(&qd.arrow); // done waiting
- return err;
- }
-
- if (mustAddContent) {
- if (err==noErr)
- err2 = AddLetterBlocks(window,infoPtr,nil);
- else
- err2 = noErr;
- }
-
- err = SMPEndSave(window,(err==noErr));
- if (err!=noErr)
- return err;
-
- if (err==noErr) {
- infoPtr->otherData[kLastChangedData] = 0;
- }
-
- SetCursor(&qd.arrow); // done waiting
-
- if (err==noErr)
- return err2;
- else
- return err;
- }
-
-
- void CommReply(WindowPtr window,Boolean replyToAll)
- {
- WindowPtr replyWindow;
- Point topLeft = {0,0};
- Str255 newTitle;
- Rect newWindRect;
- Point *ptPtr;
- OSErr err;
-
- GetResString(newTitle,kDefaultFilenameID,kDefaultFilename);
- newWindRect = window->portRect;
- SetPort(window);
- ptPtr = (Point *)&newWindRect;
- LocalToGlobal(ptPtr++);
- LocalToGlobal(ptPtr);
- OffsetRect(&newWindRect,kWindowOffset,kWindowOffset);
-
- replyWindow = MakeWindow(kDrawMailerWindow,&newWindRect,newTitle,false);
- err = SMPMailerReply(window,replyWindow,replyToAll,topLeft,true,true,gIdentity,nil,0L);
- if (err!=noErr)
- DoError(err);
- ShowWindow(replyWindow);
- }
-
-
- void CommForward(WindowPtr window)
- {
- WInfoPtr infoPtr;
- char hState;
-
- OSErr err;
-
- infoPtr = BeginWindowAccess(window,&hState);
-
- HandleExpand(window,infoPtr); // expand the window before doing the forward
-
- err = SMPMailerForward(window,gIdentity);
- if (err!=noErr)
- DoError(err);
-
- infoPtr->saved = false;
-
- DMailerActivateWindow(window,infoPtr,nil);
- EndWindowAccess(window,hState);
- }
-
-
- void CommAdjacentLetter(void)
- {
- OSErr err;
- LetterDescriptor newLetter,**oldLetter;
- OSType ltrType;
- WindowPtr window;
- WInfoPtr infoPtr;
- char hState,hState2;
-
- SetCursor(&gWatchCursor);
-
- ltrType = kCDLtrMsgType;
- err = SMPGetNextLetter(<rType,1,&newLetter);
-
- for (window=FrontWindow(); window!=nil; window=(WindowPtr)((WindowPeek)window)->nextWindow) {
- infoPtr = BeginWindowAccess(window,&hState);
- if (IsWindowType(window,kDrawMailerWindow)) {
- oldLetter = (LetterDescriptor **)infoPtr->otherData[kLetterDescData];
- hState2 = HGetState((Handle)oldLetter);
- HLock((Handle)oldLetter);
- if (SameLetter(*oldLetter,&newLetter))
- err = kInternalError; // don't open letter if it's already open
- HSetState((Handle)oldLetter,hState2);
- }
- EndWindowAccess(window,hState);
- }
-
- if (err==noErr) {
- err = LoOpen(false,nil,&newLetter.u.mailboxSpec,true,&window);
- if (err!=noErr)
- DoError(err);
- }
- else
- SysBeep(1); // no adjacent letters
-
- SetCursor(&qd.arrow);
- }
-
-
- void CommTagLetter(void)
- {
- RString32 tag;
- OSErr err;
-
- tag.dataLength = 0;
- err = SMPTagDialog(FrontWindow(),&tag);
- if (err!=noErr)
- DoError(err);
- }
-
-
- OSErr GetLocalIdentity(void)
- {
- OSErr err;
- SDPIdentityKind idKind;
- AuthGetLocalIdentityPB pBlock;
- Str255 authString;
-
- GetResString(authString,kAuthStringID,kAuthString);
-
- err = AuthGetLocalIdentity((AuthParamBlockPtr)&pBlock,false);
-
- if (err!=noErr)
- err = SDPPromptForID(&gIdentity,nil,nil,authString,nil,kSDPLocalIdentityMask,&idKind,nil,0);
- else
- gIdentity = pBlock.theLocalIdentity;
-
- return err;
- }
-
-
- OSErr ProcessAOCEEvent(WindowPtr window,WInfoPtr infoPtr,const EventRecord *ev,SMPMailerResult *mailResult)
- {
- #pragma unused (window,infoPtr)
-
- return SMPMailerEvent(ev,mailResult,nil,0L);
- }
-
-
- Boolean ProcessAOCEWhatHappened(WindowPtr window,WInfoPtr infoPtr,SMPMailerResult mailResult)
- {
- OSErr err;
- SMPMailerState state;
- long *lastChanged;
-
- // see if the mailer has changed
-
- err = SMPGetMailerState(window, &state);
- if (err != noErr)
- DoError(err);
-
- lastChanged = (long *) &infoPtr->otherData[kLastChangedData];
- if (*lastChanged!=state.changeCount) {
- *lastChanged = state.changeCount;
- infoPtr->changed = true;
- FixMailerMenus(window,infoPtr);
- }
-
- if (mailResult & kSMPContractedMask)
- HandleContract(window,infoPtr);
-
- if (mailResult & kSMPExpandedMask)
- HandleExpand(window,infoPtr);
-
- if ((mailResult & kSMPMailerBecomesTargetMask) ||
- (mailResult & kSMPAppBecomesTargetMask))
- FixMailerMenus(window,infoPtr);
-
- // actually, we want to check the menus for *every* event that the mailer handles completely, since we may
- // need to change the Undo item in the File menu to keep it up to date
-
- if (mailResult & kSMPAppShouldIgnoreEventMask)
- FixMailerMenus(window,infoPtr);
-
- if (mailResult & kSMPAppMustHandleEventMask)
- return false; // app must handle this event
- else return true; // mailer handled this event completely
- }
-
-
- void MakeMailerFromDrawing(WindowPtr window)
- {
- WInfoPtr infoPtr;
- char hState;
- Point topLeft = {0,0};
- OSErr err;
- short mWidth,contHeight,expHeight;
-
- SetWindowKind(window,kDrawMailerWindow);
-
- infoPtr = BeginWindowAccess(window,&hState);
-
- SetDMailerMethods(infoPtr);
- infoPtr->otherFlags[kMailerExpanded] = gPreferences.expandOnCreate;
-
- if (infoPtr->fRefNum) {
- err = FSClose(infoPtr->fRefNum);
- if (err!=noErr)
- DoError(err);
- infoPtr->fRefNum = 0;
- }
- if (infoPtr->resRefNum) {
- DSIGCopySigsToTemp(infoPtr);
- CloseResFile(infoPtr->resRefNum);
- err = ResError();
- if (err!=noErr)
- DoError(err);
- infoPtr->resRefNum = 0;
- }
-
- infoPtr->saved = false;
- infoPtr->changed = true;
-
- infoPtr->otherData[kLetterDescData] = nil;
-
- err = SMPNewMailer(window,topLeft,true,gPreferences.expandOnCreate,gIdentity,nil,0L);
- if (err!=noErr)
- DoError(err);
-
- err = SMPGetDimensions(&mWidth,&contHeight,&expHeight);
- if (err!=noErr)
- DoError(err);
- if (infoPtr->otherFlags[kMailerExpanded])
- infoPtr->topIndent = expHeight;
- else
- infoPtr->topIndent = contHeight;
-
- MoveScrollBars(window);
-
- EndWindowAccess(window,hState);
- }
-
-
- void MakeDrawingFromMailer(WindowPtr window)
- {
- WInfoPtr infoPtr;
- char hState;
-
- OSErr err;
-
- if (!CanCloseLetter(window)) // make sure no open enclosures
- return;
-
- err = SMPDisposeMailer(window,&gPreferences.closeOptions);
- if (err!=noErr)
- DoError(err);
-
- SetWindowKind(window,kDrawWindow);
-
- infoPtr = BeginWindowAccess(window,&hState);
-
- infoPtr->topIndent = 0;
- if (!CheckPageSize(window,infoPtr)) // draw area may have gotten too big for us
- MoveScrollBars(window);
-
- if (infoPtr->fRefNum) {
- err = FSClose(infoPtr->fRefNum);
- if (err!=noErr)
- DoError(err);
- infoPtr->fRefNum = 0;
- }
- if (infoPtr->resRefNum) {
- DSIGCopySigsToTemp(infoPtr);
- CloseResFile(infoPtr->resRefNum);
- err = ResError();
- if (err!=noErr)
- DoError(err);
- infoPtr->resRefNum = 0;
- }
-
- infoPtr->saved = false;
- infoPtr->changed = true;
-
- if (infoPtr->otherData[kLetterDescData])
- DisposHandleChk((Handle)infoPtr->otherData[kLetterDescData]);
-
- SetDrawMethods(infoPtr);
-
- EndWindowAccess(window,hState);
- }
-
-
- void FixMailerMenus(WindowPtr window,WInfoPtr infoPtr)
- {
- #pragma unused (infoPtr)
- MenuHandle theMenu;
- Str255 removeMailerText;
- OSErr err;
- SMPMailerState state;
- Boolean undoEnabled;
-
- // get mailer's state so we can set the menus
-
- err = SMPGetMailerState(window, &state);
- if (err != noErr)
- DoError(err);
-
- // edit menu
-
- theMenu = GetMHandle(kEditMenu);
- EnableAllMenuItems(theMenu);
- if (state.isTarget) {
- if (!state.canCut)
- DisableItem(theMenu, kCutItem);
- if (!state.canCopy)
- DisableItem(theMenu, kCopyItem);
- if (!state.canPaste)
- DisableItem(theMenu, kPasteItem);
- if (!state.canClear)
- DisableItem(theMenu, kClearItem);
- if (!state.canSelectAll)
- DisableItem(theMenu, kSelectAllItem);
- }
- else
- FixDrawEditMenu();
-
- // fix undo item
-
- switch (state.undoState) {
- case kSMPMailerUndo:
- SetItem(theMenu,kUndoItem,state.undoWhat);
- EnableItem(theMenu,kUndoItem);
- ClearAppUndo();
- undoEnabled = true;
- break;
- case kSMPUndoDisabled:
- ClearAppUndo();
- undoEnabled = SetupAppUndo();
- break;
- case kSMPAppMayUndo:
- undoEnabled = SetupAppUndo();
- break;
- }
-
- if (state.isTarget && !state.canCut && !state.canCopy && !state.canPaste && !state.canClear &&
- !state.canSelectAll && !undoEnabled)
- DisableItem(theMenu,0); // disable edit menu title
-
- // mail menu
-
- theMenu = GetMHandle(kMailMenu);
- EnableAllMenuItems(theMenu);
- GetResString(removeMailerText,kRemoveMailerTextID,kRemoveMailerText);
- SetItem(theMenu,kAddRemMailItem,removeMailerText);
- if (state.hasBeenReceived) {
- DisableItem(theMenu, kSendItem);
- }
- else {
- DisableItem(theMenu, kReplyItem);
- DisableItem(theMenu, kReplyToAllItem);
- DisableItem(theMenu, kForwardItem);
- DisableItem(theMenu, kTagLetterItem);
- }
-
- gMenusDirty = true;
- }
-
-
- pascal void DrawImageProc(long refCon, Boolean inColor)
- {
- #pragma unused (inColor)
- OpenCPicParams newHeader;
- OSErr err;
- Point zeroPt = {0,0};
- WInfoPtr infoPtr;
- TPrInfo prInfo;
-
- infoPtr = (WInfoPtr)refCon;
- prInfo = (**(infoPtr->printRecord)).prInfo;
-
- newHeader.srcRect = prInfo.rPage;
- newHeader.hRes = FixRatio(prInfo.iHRes,1);
- newHeader.vRes = FixRatio(prInfo.iVRes,1);
- newHeader.version = -2;
- newHeader.reserved1 = 0;
- newHeader.reserved2 = 0L;
-
- err = SMPNewPage(&newHeader);
- if (err!=noErr)
- DoError(err);
-
- DrawAllShapes(infoPtr,zeroPt);
- }
-
-
- pascal PicHandle DrawImageToPicture(WindowPtr window,WInfoPtr infoPtr)
- {
- PicHandle thePicture;
- RgnHandle saveRgn;
- GrafPtr savePort;
- Point zeroPt = {0,0};
- TPrInfo prInfo;
-
- prInfo = (**(infoPtr->printRecord)).prInfo;
-
- GetPort(&savePort);
- SetPort(window);
- saveRgn = NewRgn();
- GetClip(saveRgn);
- ClipRect(&prInfo.rPage);
- thePicture = OpenPicture(&prInfo.rPage);
- DrawAllShapes(infoPtr,zeroPt);
- ClosePicture();
- SetClip(saveRgn);
- DisposeRgn(saveRgn);
- SetPort(savePort);
-
- return thePicture;
- }
-
-
- /*---------------------------------------------------------------------------*/
-
- OSErr AddLetterBlocks(WindowPtr window,WInfoPtr infoPtr,SMPSendFormat *sendFormat)
- {
- OSErr err = noErr;
-
- // add image
-
- if (!sendFormat || (sendFormat->whichFormats&kSMPImageMask)) {
- err = AddLetterImage(window,infoPtr);
- if (err!=noErr)
- return err;
- }
-
- // add standard letter interchange format
-
- if (!sendFormat || (sendFormat->whichFormats&kSMPStandardInterchangeMask)) {
- err = AddStandardLetterContent(window,infoPtr);
- if (err!=noErr)
- return err;
- }
-
- // add main (content) enclosure
-
- if (!sendFormat || (sendFormat->whichFormats&kSMPNativeMask)) {
- err = AddContentEnclosure(window,infoPtr);
- if (err!=noErr)
- return err;
- }
-
- return err;
- }
-
-
- OSErr AddContentEnclosure(WindowPtr window,WInfoPtr infoPtr)
- {
- OSErr err;
- FSSpec fSpec;
-
- err = SaveFileToTemp(infoPtr,&fSpec);
- if (err!=noErr)
- return err;
-
- err = SMPAddMainEnclosure(window,&fSpec);
-
- FSpDelete(&fSpec);
-
- return err;
- }
-
-
- OSErr AddStandardLetterContent(WindowPtr window,WInfoPtr infoPtr)
- {
- OSErr err;
- PicHandle thePicture;
-
- thePicture = DrawImageToPicture(window,infoPtr);
- if (thePicture) {
- HLock((Handle)thePicture);
- err = SMPAddContent(window,kMailPictSegmentType,false,*thePicture,
- GetHandleSize((Handle)thePicture),nil,true,smRoman);
- KillPicture(thePicture);
- }
- else return kInternalError;
-
- return err;
- }
-
-
- OSErr AddLetterImage(WindowPtr window,WInfoPtr infoPtr)
- {
- return SMPImage(window,DrawImageProc,(long)infoPtr,false);
- }
-
-
- void HandleExpand(WindowPtr window,WInfoPtr infoPtr)
- {
- OSErr err;
- Rect rectToInval;
- GrafPtr savePort;
- short expHeight,contHeight,mWidth;
-
- err = SMPGetDimensions(&mWidth,&contHeight,&expHeight);
- if (err!=noErr)
- DoError(err);
-
- infoPtr->otherFlags[kMailerExpanded] = true;
- infoPtr->topIndent = expHeight;
-
- rectToInval = window->portRect;
- rectToInval.top += expHeight;
- rectToInval.bottom -= kScrollBarWidth;
- rectToInval.right -= kScrollBarWidth;
-
- GetPort(&savePort);
- SetPort(window);
- InvalRect(&rectToInval);
-
- MoveScrollBars(window);
-
- err = SMPExpandOrContract(window, true);
- // ignore errors- we may already be expanded
-
- SetPort(savePort);
- }
-
-
- void HandleContract(WindowPtr window,WInfoPtr infoPtr)
- {
- OSErr err;
- Rect rectToInval;
- GrafPtr savePort;
- short expHeight,contHeight,mWidth;
-
- err = SMPGetDimensions(&mWidth,&contHeight,&expHeight);
- if (err!=noErr)
- DoError(err);
-
- infoPtr->otherFlags[kMailerExpanded] = false;
- infoPtr->topIndent = contHeight;
-
- rectToInval = window->portRect;
- rectToInval.top += contHeight;
- rectToInval.bottom -= kScrollBarWidth;
- rectToInval.right -= kScrollBarWidth;
-
- GetPort(&savePort);
- SetPort(window);
- InvalRect(&rectToInval);
-
- if (!CheckPageSize(window,infoPtr)) // draw area may have gotten too big for us
- MoveScrollBars(window);
-
- // note that we don't call ExpandOrContract() to contract mailer- it's done by mail package
-
- SetPort(savePort);
- }
-
-
- Boolean CanCloseLetter(WindowPtr window)
- {
- OSErr err;
- WInfoPtr infoPtr;
- char hState;
- Boolean returnValue;
-
- returnValue = true;
- infoPtr = BeginWindowAccess(window,&hState);
-
- if (IsWindowType(window,kDrawMailerWindow)) {
-
- // display close options dialog
-
- if (gPreferences.closeOptionsDialog) {
- SetCursor(&qd.arrow);
- err = SMPCloseOptionsDialog(window,&gPreferences.closeOptions);
- if (err!=noErr)
- returnValue = false;
- }
-
- if (returnValue==true) {
-
- // close main enclosure (if we're a received letter)
-
- if (infoPtr->fRefNum) {
- err = FSClose(infoPtr->fRefNum);
- if (err!=noErr)
- DoError(err);
- infoPtr->fRefNum = 0;
- }
- if (infoPtr->resRefNum) {
- CloseResFile(infoPtr->resRefNum);
- err = ResError();
- if (err!=noErr)
- DoError(err);
- infoPtr->resRefNum = 0;
- }
-
- // see if we can close the letter now
-
- err = SMPPrepareToClose(window);
- if (err==kSMPHasOpenAttachments) {
- SetCursor(&qd.arrow);
- StopAlert(kHasOpenAttachID,nil);
- returnValue = false;
- }
- }
- }
-
- EndWindowAccess(window,hState);
- return returnValue;
- }
-
-
- Boolean SameLetter(const LetterDescriptor *one,const LetterDescriptor *two)
- {
- if (one->onDisk != two->onDisk)
- return false;
-
- if (one->onDisk) {
-
- // compare fsspecs
-
- return ((one->u.fileSpec.vRefNum == two->u.fileSpec.vRefNum) &&
- (one->u.fileSpec.parID == two->u.fileSpec.parID) &&
- EqualString(one->u.fileSpec.name,two->u.fileSpec.name,false,true));
- }
- else {
-
- // compare letterspecs
-
- return ((one->u.mailboxSpec.spec[0] == two->u.mailboxSpec.spec[0]) &&
- (one->u.mailboxSpec.spec[1] == two->u.mailboxSpec.spec[1]) &&
- (one->u.mailboxSpec.spec[2] == two->u.mailboxSpec.spec[2]));
- }
- }